from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path,include
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView

from dj_interview_api_server import settings

'''
Swagger UI: http://localhost:8000/api/schema/swagger-ui/
ReDoc: http://localhost:8000/api/schema/redoc/
原始 OpenAPI JSON: http://localhost:8000/api/schema/
'''
urlpatterns = [
    path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
    # Optional UI:
    path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
    path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
    path('admin/', admin.site.urls),
    path('',include('home.urls',namespace='home')),
]

# 托管媒体文件(给媒体文件设置路由规则): 仅限于开发阶段, 因为这种方式性能比较差
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
